package com.lmpop.updateHtml.updateHtml;

import java.io.File;
import java.util.Hashtable;
import java.util.Map;

import com.lmpop.createIndex.search.CommparaIndexFiles;
import com.lmpop.frame.util.Config;
import com.lmpop.trade.tb_commpara.Tb_commparaInfo;
import com.lmpop.trade.ti_attach.Ti_attachInfo;
import com.lmpop.trade.ti_tradestate.Ti_tradestateInfo;
import com.lmpop.trade.ts_area.Ts_areaInfo;
import com.lmpop.trade.ts_category.Ts_categoryInfo;
import com.lmpop.trade.ts_categoryattr.Ts_categoryattrInfo;
import com.lmpop.trade.ts_memlevel.Ts_memlevelInfo;
import com.lmpop.trade.ts_module.Ts_moduleInfo;
import com.lmpop.trade.uploadFile.ReturnImgWH;

public class SpecialField
{
  public Config config;
  public String news_article_path;
  public String b2cnews_article_path;
  public String zhuanti_article_path;
  public String goods_article_path;
  public String job_article_path;
  public String resume_article_path;
  public String teambuy_article_path;
  public String company_shop_path;
  public String news_list_url;
  public String goodss_list_url;
  public String warehouse_article_path;
  public String normalbiz_path;
  public String pricedetail_path;
  public String jobdetail_path;
  public String goodsurl_path;
  public String _8diantuanteambuyurl_path;
  public String carlink_path;
  public String noimg_path;
  public String bidding_path;
  public String resume_savepath;
  public String training_savepath;
  public String show_path;
  public String product_path;
  public String company_path;
  public String ask_path;
  public String knowledge_path;
  public String product_article_path;
  public String teambuy_path;
  public Tb_commparaInfo comm;
  public Ts_moduleInfo moduleInfo;

  public SpecialField()
  {
    this.config = new Config();
    this.moduleInfo = new Ts_moduleInfo();
    this.noimg_path = this.config.getString("noimg_path");
    this.ask_path = this.moduleInfo.getSavaPathByCode("ask");
    this.knowledge_path = this.moduleInfo.getSavaPathByCode("knowledge");
    this.news_article_path = this.moduleInfo.getSavaPathByCode("news");
    this.b2cnews_article_path = this.moduleInfo.getSavaPathByCode("b2cnews");
    this.show_path = this.moduleInfo.getSavaPathByCode("showinfo");
    this.normalbiz_path = this.moduleInfo.getSavaPathByCode("normalbiz");
    this.carlink_path = this.moduleInfo.getSavaPathByCode("srccar");
    this.company_path = this.moduleInfo.getSavaPathByCode("company_path");
    this.goodsurl_path = this.moduleInfo.getSavaPathByCode("goods");
    this._8diantuanteambuyurl_path = this.moduleInfo.getSavaPathByCode("_8diantuanteambuy");
    this.jobdetail_path = this.moduleInfo.getSavaPathByCode("recruit");
    this.bidding_path = this.moduleInfo.getSavaPathByCode("bidding");
    this.resume_savepath = this.moduleInfo.getSavaPathByCode("resume");
    this.teambuy_article_path = this.moduleInfo.getSavaPathByCode("b2cteambuy");
    this.warehouse_article_path = this.moduleInfo.getSavaPathByCode("warehouse");
    this.product_article_path = this.moduleInfo.getSavaPathByCode("product");
    this.training_savepath = this.moduleInfo.getSavaPathByCode("training");
    this.pricedetail_path = this.moduleInfo.getSavaPathByCode("pricedetail");
    this.goodss_list_url = this.config.getString("goodss_list_url");
    this.comm = new Tb_commparaInfo();
  }

  public String getArticleVlaue(String name, Map map)
  {
    String value = "";

    if (name.equals("get_cat_attr")) {
      value = getNewsChAttr(map);
    }
    if (name.equals("imgurl")) {
      value = getImgurl(map);
    }
    if (name.equals("custlogo")) {
      value = getCustlogo(map);
    }
    if (name.equals("check_file_path")) {
      value = getCheckImgurl(map);
    }

    if (name.equals("companyurl")) {
      value = getCompanyUrl(map, this.company_path);
    }
    if (name.equals("knowledgeurl")) {
      value = getArticleUrl(map, this.knowledge_path);
    }
    if (name.equals("supplyurl")) {
      value = getArticleUrl(map, this.normalbiz_path);
    }
    if (name.equals("askurl")) {
      value = getArticleUrl(map, this.ask_path);
    }
    if (name.equals("teambuyurl")) {
      value = getArticleUrl(map, this.teambuy_article_path);
    }
    if (name.equals("_8diantuanteambuyurl")) {
      value = getArticleUrl(map, this._8diantuanteambuyurl_path);
    }
    if (name.equals("showurl")) {
      value = getArticleUrl(map, this.show_path);
    }
    if (name.equals("producturl")) {
      value = getArticleUrl(map, this.product_article_path);
    }
    if (name.equals("priceurl")) {
      value = getArticleUrl(map, this.pricedetail_path);
    }
    if (name.equals("recruiturl")) {
      value = getArticleUrl(map, this.jobdetail_path);
    }
    if (name.equals("trainingurl")) {
      value = getArticleUrl(map, this.training_savepath);
    }
    if (name.equals("carlink")) {
      value = getArticleUrl(map, this.carlink_path);
    }
    if (name.equals("resumeurl")) {
      value = getArticleUrl(map, this.resume_savepath);
    }
    if (name.equals("goodsurl")) {
      value = getArticleUrl(map, this.goodsurl_path);
    }
    if (name.equals("houseurl")) {
      value = getArticleUrl(map, this.warehouse_article_path);
    }
    if (name.equals("biddingurl")) {
      value = getBiddingUrl(map, this.bidding_path);
    }
    if (name.equals("class_attr")) {
      value = dealClassAttr(map);
    }
    if (name.equals("class_attr_b2c")) {
      value = dealClassAttrB2c(map);
    }
    if (name.equals("attr_desc_check")) {
      value = dealAttrdescCheckbox(map);
    }
    if (name.equals("member_price")) {
      value = dealMemberprice(map);
    }
    if (name.equals("attr_desc")) {
      value = dealArticleAttrdesc(map);
    }
    if (name.equals("custimg")) {
      value = getcustImg(map);
    }
    if (name.equals("areaAttr")) {
      value = getareaAttr(map);
    }
    if (name.equals("area_attr")) {
      value = getareaAttr(map);
    }

    if (name.equals("account_location")) {
      value = getlocationAttr(map);
    }
    if (name.equals("q_work_addr")) {
      value = getwork_addr(map);
    }
    if (name.equals("clientStatus")) {
      value = getclientStatus(map);
    }
    if (name.equals("client_status")) {
      value = getclientStatus(map);
    }
    if (name.equals("custType")) {
      value = getcustType(map);
    }
    if (name.equals("classAttr")) {
      value = getcustAttr(map);
    }
    if (name.equals("start_addr")) {
      value = getStartAddr(map);
    }
    if (name.equals("end_addr")) {
      value = getEndAddr(map);
    }
    if (name.equals("trade_state")) {
      value = getTradeState(map);
    }

    return value;
  }

  public String getListVlaue(String name, Map map) {
    String value = "";

    if (name.equals("title")) {
      value = getTitle(map);
    }
    if (name.equals("imgurl")) {
      value = getImgurl(map);
    }
    if (name.equals("custlogo")) {
      value = getCustlogo(map);
    }
    if (name.equals("churl")) {
      value = getchurl(map);
    }
    if (name.equals("check_file_path")) {
      value = getCheckImgurl(map);
    }
    if (name.equals("resumeurl")) {
      value = getArticleUrl(map, this.resume_savepath);
    }
    if (name.equals("companyurl")) {
      value = getCompanyUrl(map, this.company_path);
    }
    if (name.equals("producturl")) {
      value = getArticleUrl(map, this.product_article_path);
    }
    if (name.equals("knowledgeurl")) {
      value = getArticleUrl(map, this.knowledge_path);
    }
    if (name.equals("askurl")) {
      value = getArticleUrl(map, this.ask_path);
    }

    if (name.equals("_8diantuanteambuyurl")) {
      value = getArticleUrl(map, this._8diantuanteambuyurl_path);
    }
    if (name.equals("teambuyurl")) {
      value = getArticleUrl(map, this.teambuy_article_path);
    }
    if (name.equals("recruiturl")) {
      value = getArticleUrl(map, this.jobdetail_path);
    }
    if (name.equals("showurl")) {
      value = getArticleUrl(map, this.show_path);
    }
    if (name.equals("trainingurl")) {
      value = getArticleUrl(map, this.training_savepath);
    }
    if (name.equals("newsurl")) {
      value = getnewsurl(map);
    }

    if (name.equals("b2cnewsurl")) {
      value = getb2cnewsurl(map);
    }

    if (name.equals("supplyurl")) {
      value = getArticleUrl(map, this.normalbiz_path);
    }
    if (name.equals("priceurl")) {
      value = getArticleUrl(map, this.pricedetail_path);
    }
    if (name.equals("carlink")) {
      value = getArticleUrl(map, this.carlink_path);
    }
    if (name.equals("goodsurl")) {
      value = getArticleUrl(map, this.goodsurl_path);
    }
    if (name.equals("houseurl")) {
      value = getArticleUrl(map, this.warehouse_article_path);
    }
    if (name.equals("biddingurl")) {
      value = getBiddingUrl(map, this.bidding_path);
    }

    if (name.equals("zhuantiurl")) {
      value = getzhuantiurl(map);
    }
    if (name.equals("imgwidth")) {
      value = getImgwidth(map);
    }
    if (name.equals("imgheight")) {
      value = getImgheight(map);
    }
    if (name.equals("content_sub")) {
      value = getcontent_sub(map);
    }
    if (name.equals("in_date")) {
      value = dealDate(map);
    }
    if (name.equals("custurl")) {
      value = getCustUrl(map);
    }
    if (name.equals("goods_attr")) {
      value = dealGoodsAttr(map);
    }
    if (name.equals("areaAttr")) {
      value = getareaAttr(map);
    }
    if (name.equals("classAttr")) {
      value = getcustAttr(map);
    }
    if (name.equals("start_addr")) {
      value = getStartAddr(map);
    }
    if (name.equals("end_addr")) {
      value = getEndAddr(map);
    }
    if (name.equals("class_attr")) {
      value = dealClassAttr(map);
    }

    if (name.equals("area_attr")) {
      value = getareaAttr(map);
    }
    if (name.equals("trade_state")) {
      value = getTradeState(map);
    }
    return value;
  }

  public String dealClassAttrB2c(Map map)
  {
    System.out.println("dealClassAttrB2c");
    Ts_categoryInfo catInfo = new Ts_categoryInfo();
    Map catMap = catInfo.getCatClassMap("2");
    String class_attr = "";
    StringBuffer classb = new StringBuffer();
    if (map.get("class_attr_b2c") != null) class_attr = map.get("class_attr_b2c").toString();
    if (!class_attr.equals("")) {
      String[] cat_attr = class_attr.split("\\|");
      if (cat_attr.length > 0) {
        for (int i = 0; i < cat_attr.length; i++) {
          String cat_one = cat_attr[i];
          if ((!cat_one.equals("")) && (catMap.get(cat_one) != null)) {
            System.out.println("catMap.get(cat_one)=================" + catMap.get(cat_one));
            classb.append("<a href='" + this.goodss_list_url + "?cat_id_para=" + cat_one + "' target='_blank'>" + catMap.get(cat_one).toString() + "</a> > ");
          }
        }
      }
    }
    return classb.toString();
  }

  public String dealClassAttr(Map map) {
    String attr = "";
    String cat_name = "";
    Ts_categoryInfo category = new Ts_categoryInfo();
    if ((map.get("class_attr") != null) && (!map.get("class_attr").toString().equals(""))) {
      attr = map.get("class_attr").toString();
      String[] catIds = attr.split("\\|");
      if (!catIds.equals("")) {
        for (int k = 0; k < catIds.length; k++) {
          cat_name = cat_name + category.getCatNameById(catIds[k]) + "&nbsp;";
        }
      }
    }
    return cat_name;
  }

  public String getNewsChAttr(Map map) {
    Ts_categoryInfo catInfo = new Ts_categoryInfo();
    Map channelMap = catInfo.getAllChClass();
    String class_attr = "";
    StringBuffer classb = new StringBuffer();
    if (map.get("cat_attr") != null) class_attr = map.get("cat_attr").toString();
    if (!class_attr.equals("")) {
      String[] cat_attr = class_attr.split("\\|");
      if (cat_attr.length > 0) {
        for (int i = 0; i < cat_attr.length; i++) {
          String cat_one = cat_attr[i];
          if ((!cat_one.equals("")) && (channelMap.get(cat_one) != null)) {
            classb.append("<a href='" + this.news_list_url + "?cat_attr=" + cat_one + "' target='_blank'>" + channelMap.get(cat_one).toString() + "</a>&gt;");
          }
        }
      }
    }
    return classb.toString();
  }

  public String dealMemberprice(Map map)
  {
    Ts_memlevelInfo meml = new Ts_memlevelInfo();
    Map levelMap = meml.getAll();
    StringBuffer price_dis = new StringBuffer();
    String member_price = "";
    if (map.get("member_price") != null) member_price = map.get("member_price").toString();
    if ((!member_price.equals("")) && (member_price.indexOf(",") > -1)) {
      String[] mem = member_price.split(",");
      if (mem.length > 0) {
        for (int i = 0; i < mem.length; i++) {
          String mem_one = mem[i];
          if ((!mem_one.equals("")) && (mem_one.indexOf("|") > -1)) {
            String[] mem_one_son = mem_one.split("\\|");
            if (mem_one_son.length > 1) {
              String level_id = mem_one_son[0];
              String price = mem_one_son[1];
              String level_name = "";
              if (levelMap.get(level_id) != null) {
                level_name = levelMap.get(level_id).toString();
              }
              price_dis.append(level_name + ":fuhao<font color=#C56897>" + price + "</font>yuan&nbsp;");
            }
          }
        }
      }
    }
    return price_dis.toString();
  }

  public String dealAttrdescCheckbox(Map map)
  {
    String check = "checkbox_value_";
    Ts_categoryattrInfo catattr = new Ts_categoryattrInfo();
    Map attrMap = catattr.getAllCatAttr();
    StringBuffer attrSb = new StringBuffer();
    String attr_desc = "";
    if (map.get("attr_desc") != null) attr_desc = map.get("attr_desc").toString();

    if (!attr_desc.equals("")) {
      String[] attr = attr_desc.split(",");
      if (attr.length > 0) {
        for (int i = 0; i < attr.length; i++) {
          String attr_one = attr[i];
          if ((!attr_one.equals("")) && (attr_one.indexOf("|") > -1)) {
            String[] attr_one_this = attr_one.split("\\|");
            if (attr_one_this.length > 2) {
              String attr_id = attr_one_this[0];
              String attr_name = "";
              if ((!attr_id.equals("")) && (attrMap.get(attr_id) != null)) {
                attr_name = attrMap.get(attr_id).toString();
              }
              attrSb.append("<div class='color_div'>");
              attrSb.append("<P class='color'><span class='cont_t_r_b_sp'>" + attr_name + ":</span></P>");
              attrSb.append("<input type='hidden' name='checkbox_name_" + i + "' id='checkbox_name_" + i + "' value='" + attr_name + "' /> ");
              attrSb.append("<input type='hidden' name='checkbox_value_" + i + "' id='checkbox_value_" + i + "' value='' /> ");
              attrSb.append("<ul class='color_ul'>");

              for (int j = 1; j < attr_one_this.length; j++) {
                attrSb.append("<li onclick=\"setAttrdesc(" + j + "," + (attr_one_this.length - 1) + ",'" + attr_id + "','" + attr_one_this[j] + "','" + check + "" + i + "');\" id=\"" + attr_id + j + "\">" + attr_one_this[j] + "</li>");
              }

              attrSb.append("</ul>");
              attrSb.append("</div>");
            }
          }
        }
      }
    }

    return attrSb.toString();
  }

  public String dealArticleAttrdesc(Map map) {
    Ts_categoryattrInfo catattr = new Ts_categoryattrInfo();
    Map attrMap = catattr.getAllCatAttr();
    StringBuffer attrSb = new StringBuffer();
    String attr_desc = "";
    if (map.get("attr_desc") != null) attr_desc = map.get("attr_desc").toString();

    if (!attr_desc.equals("")) {
      String[] attr = attr_desc.split(",");
      if (attr.length > 0) {
        for (int i = 0; i < attr.length; i++) {
          String attr_one = attr[i];

          if ((i + 1) % 2 != 0) attrSb.append("<tr>");

          if ((!attr_one.equals("")) && (attr_one.indexOf("|") > -1)) {
            String[] attr_one_this = attr_one.split("\\|");
            if (attr_one_this.length > 1) {
              String attr_id = attr_one_this[0];
              StringBuffer attr_value = new StringBuffer();
              for (int j = 1; j < attr_one_this.length; j++) {
                attr_value.append(attr_one_this[j] + " ");
              }
              String attr_name = "";
              if ((!attr_id.equals("")) && (attrMap.get(attr_id) != null)) {
                attr_name = attrMap.get(attr_id).toString();
              }

              if ((i + 1) % 2 != 0) {
                attrSb.append("<td width='15%' class='lefttd'>" + attr_name + ":</td>");
                attrSb.append("<td width='35%' class='righttd'>" + attr_value + "</td>");
              }
              if ((i + 1) % 2 == 0) {
                attrSb.append("<td width='15%' class='lefttd'>" + attr_name + ":</td>");
                attrSb.append("<td class='righttd'>" + attr_value + "</td>");
              }
            }
          }

          if ((i + 1) % 2 != 0) continue; attrSb.append("</tr>");
        }

        if (attr.length % 2 != 0) {
          attrSb.append("<td width='15%' class='lefttd'></td>");
          attrSb.append("<td class='righttd'></td>");
          attrSb.append("</tr>");
        }
      }
    }
    return attrSb.toString();
  }

  public String dealGoodsAttr(Map map)
  {
    Ts_categoryattrInfo catattr = new Ts_categoryattrInfo();
    Map attrMap = catattr.getAllCatAttr();
    String goods_attr = "";
    StringBuffer attrSb = new StringBuffer();
    if (map.get("goods_attr") != null) goods_attr = map.get("goods_attr").toString();
    if (!goods_attr.equals("")) {
      String[] attr = goods_attr.split(",");
      if (attr.length > 0) {
        for (int i = 0; i < attr.length; i++) {
          String attr_one = attr[i];
          if ((!attr_one.equals("")) && (attr_one.indexOf("|") > -1)) {
            String[] attr_one_this = attr_one.split("\\|");
            if (attr_one_this.length > 1) {
              String attr_id = attr_one_this[0];
              String attr_value = attr_one_this[1];
              String attr_name = "";
              if ((!attr_id.equals("")) && (attrMap.get(attr_id) != null)) {
                attr_name = attrMap.get(attr_id).toString();
              }
              attrSb.append(attr_name + ":" + attr_value + ";");
            }
          }
        }
      }
    }
    return attrSb.toString();
  }

  public String getTitle(Map map)
  {
    String title = "";
    int titlelen = 0;
    if (map.get("title") != null) title = map.get("title").toString();
    if ((map.get("titlelen") != null) && (!map.get("titlelen").toString().equals(""))) {
      titlelen = Integer.parseInt(map.get("titlelen").toString());
    }
    if ((title.length() > titlelen) && (titlelen > 0)) title = title.substring(0, titlelen);
    return title;
  }

  public String getcontent_sub(Map map)
  {
    String content_sub = "";
    int infolen = 0;
    if (map.get("content_sub") != null) content_sub = map.get("content_sub").toString();
    if ((map.get("infolen") != null) && (!map.get("infolen").toString().equals(""))) {
      infolen = Integer.parseInt(map.get("infolen").toString());
    }
    if ((content_sub.length() > infolen) && (infolen > 0)) content_sub = content_sub.substring(0, infolen);
    return content_sub;
  }

  public String getContentSub(Map map)
  {
    String content_sub = "";
    int infolen = 0;
    if (map.get("content_sub") != null) content_sub = map.get("content_sub").toString();
    if ((map.get("infolen") != null) && (!map.get("infolen").toString().equals(""))) {
      infolen = Integer.parseInt(map.get("infolen").toString());
    }
    if ((content_sub.length() > infolen) && (infolen > 0)) content_sub = content_sub.substring(0, infolen);
    return content_sub;
  }

  public String getImgurl(Map map)
  {
    String info_id = "";
    String imgurl = "";
    if (map.get("info_id") != null) info_id = map.get("info_id").toString();

    Ti_attachInfo attachinfo = new Ti_attachInfo();
    imgurl = attachinfo.getFilePathByAttachrootid(info_id);
    if (imgurl.equals("")) imgurl = this.noimg_path;
    return imgurl;
  }

  public String getCustlogo(Map map) {
    String cust_id = "";
    String imgurl = "";
    if (map.get("cust_id") != null) cust_id = map.get("cust_id").toString();

    Ti_attachInfo attachinfo = new Ti_attachInfo();
    imgurl = attachinfo.getFilePathByAttachrootid(cust_id);
    if (imgurl.equals("")) imgurl = this.noimg_path;
    return imgurl;
  }

  public String getCheckImgurl(Map map) {
    String imgurl = "";
    if (map.get("file_path") != null) imgurl = map.get("file_path").toString();
    if (imgurl.equals("")) imgurl = this.noimg_path;
    return imgurl;
  }

  public String getgoodsurl(Map map)
  {
    String info_id = ""; String in_date = "";
    if (map.get("info_id") != null) info_id = map.get("info_id").toString();
    if (map.get("in_date") != null) in_date = map.get("in_date").toString();
    if (in_date.length() > 10) in_date = in_date.substring(0, 10);
    return this.goods_article_path + in_date + "/" + info_id + ".html";
  }

  public String getArticleUrl(Map map, String path) {
    String info_id = ""; String in_date = "";
    if (map.get("info_id") != null) info_id = map.get("info_id").toString();
    if (map.get("in_date") != null) in_date = map.get("in_date").toString();
    if (in_date.length() > 10) in_date = in_date.substring(0, 10);
    System.out.println("getArticleUrl: " + path + in_date + "/" + info_id + ".html");
    return path + in_date + "/" + info_id + ".html";
  }

  public String getCompanyUrl(Map map, String path) {
    String info_id = ""; String companyurl = "";
    if (map.get("info_id") != null) info_id = map.get("info_id").toString();
    if (map.get("cust_id") != null) info_id = map.get("cust_id").toString();
    this.config = new Config();
    String root_path = this.config.getString("rootpath");
    File file = new File(root_path + "/data/company/" + info_id + "/index.html");
    if (!file.exists())
    {
      companyurl = "/company.html?cust_id=" + info_id;
    }
    else
    {
      companyurl = "/data/company/" + info_id;
    }

    return companyurl;
  }
  public String getBiddingUrl(Map map, String path) {
    String bid_id = ""; String in_date = "";
    if (map.get("bid_id") != null) bid_id = map.get("bid_id").toString();
    if (map.get("in_date") != null) in_date = map.get("in_date").toString();
    if (in_date.length() > 10) in_date = in_date.substring(0, 10);
    return "/data/bidding/" + in_date + "/" + bid_id + ".html";
  }

  public String getJobUrl(Map map)
  {
    String info_id = ""; String in_date = "";
    if (map.get("info_id") != null) info_id = map.get("info_id").toString();
    if (map.get("in_date") != null) in_date = map.get("in_date").toString();
    if (in_date.length() > 10) in_date = in_date.substring(0, 10);
    return this.job_article_path + in_date + "/" + info_id + ".html";
  }

  public String getResumeUrl(Map map)
  {
    String info_id = ""; String in_date = "";
    if (map.get("info_id") != null) info_id = map.get("info_id").toString();
    if (map.get("in_date") != null) in_date = map.get("in_date").toString();
    if (in_date.length() > 10) in_date = in_date.substring(0, 10);
    return this.resume_article_path + in_date + "/" + info_id + ".html";
  }

  public String getnewsurl(Map map)
  {
    String news_url = "";
    if ((map.get("out_link") != null) && (!map.get("out_link").toString().trim().equals(""))) {
      news_url = map.get("out_link").toString();
    } else {
      String info_id = ""; String in_date = "";
      if (map.get("info_id") != null) info_id = map.get("info_id").toString();
      if (map.get("in_date") != null) in_date = map.get("in_date").toString();
      if (in_date.length() > 10) in_date = in_date.substring(0, 10);
      news_url = this.news_article_path + in_date + "/" + info_id + ".html";
    }
    return news_url;
  }

  public String getb2cnewsurl(Map map) {
    String b2cnews_url = "";
    if ((map.get("out_link") != null) && (!map.get("out_link").toString().trim().equals(""))) {
      b2cnews_url = map.get("out_link").toString();
    } else {
      String info_id = ""; String in_date = "";
      if (map.get("info_id") != null) info_id = map.get("info_id").toString();
      if (map.get("in_date") != null) in_date = map.get("in_date").toString();
      if (in_date.length() > 10) in_date = in_date.substring(0, 10);
      b2cnews_url = this.b2cnews_article_path + in_date + "/" + info_id + ".html";
    }
    return b2cnews_url;
  }

  public String getchurl(Map map) {
    String remark = ""; String cat_id = ""; String churl = "";
    if (map.get("cat_id") != null) {
      cat_id = map.get("cat_id").toString();
    }
    if ((map.get("remark") != null) && (!map.get("remark").toString().trim().equals("")))
      churl = map.get("remark").toString().trim();
    else {
      churl = "/news_list.html?cat_id=" + cat_id;
    }
    return churl;
  }
  public String getzhuantiurl(Map map) {
    String info_id = ""; String in_date = "";
    if (map.get("info_id") != null) info_id = map.get("info_id").toString();
    if (map.get("in_date") != null) in_date = map.get("in_date").toString();
    if (in_date.length() > 10) in_date = in_date.substring(0, 10);
    return this.zhuanti_article_path + in_date + "/" + info_id + ".html";
  }

  public String getCustUrl(Map map) {
    String info_id = "";

    String companyurl = "";
    if (map.get("info_id") != null) info_id = map.get("info_id").toString();
    if (map.get("cust_id") != null) info_id = map.get("cust_id").toString();

    this.config = new Config();
    String root_path = this.config.getString("rootpath");
    File file = new File(root_path + "/data/company/" + info_id + "/index.html");
    if (!file.exists())
    {
      companyurl = "/company.html?cust_id=" + info_id;
    }
    else
    {
      companyurl = "/data/company/" + info_id;
    }

    return companyurl;
  }

  public String dealDate(Map map)
  {
    String in_date = "";
    int datelen = 0; int datefrom = 0;
    if ((map.get("datefrom") != null) && (!map.get("datefrom").toString().equals(""))) datefrom = Integer.parseInt(map.get("datefrom").toString());
    if ((map.get("datelen") != null) && (!map.get("datelen").toString().equals(""))) datelen = Integer.parseInt(map.get("datelen").toString());
    if (map.get("in_date") != null) in_date = map.get("in_date").toString();
    if (in_date.length() > datelen) in_date = in_date.substring(datefrom, datelen);
    return in_date;
  }

  public String getImgWH(Map map, String type)
  {
    int imgwidth = 0; int imgheight = 0;
    if ((map.get("imgwidth") != null) && (!map.get("imgwidth").toString().equals(""))) imgwidth = Integer.parseInt(map.get("imgwidth").toString());
    if ((map.get("imgheight") != null) && (!map.get("imgheight").toString().equals(""))) imgheight = Integer.parseInt(map.get("imgheight").toString());
    String imgurl = getImgurl(map);
    String rootpath = this.config.getString("rootpath");
    String img_path = rootpath + imgurl;
    ReturnImgWH retwh = new ReturnImgWH();
    File file = new File(img_path);
    String dis_imgwidth = "0"; String dis_imgheight = "0";
    if (file.exists()) {
      int[] a = retwh.returnSrcImgWH(img_path);
      int[] b = retwh.returnDisImgWH(a, imgwidth, imgheight);
      dis_imgwidth = String.valueOf(b[0]);
      dis_imgheight = String.valueOf(b[1]);
    }
    String result_str = "";
    if (type.equals("width")) result_str = dis_imgwidth;
    if (type.equals("height")) result_str = dis_imgheight;
    return result_str;
  }

  public String getImgheight(Map map) {
    return getImgWH(map, "height");
  }

  public String getImgwidth(Map map) {
    return getImgWH(map, "width");
  }

  public String getcustType(Map map)
  {
    String type = "";
    if ((map.get("cust_type") != null) && (!map.get("cust_type").toString().equals(""))) {
      type = map.get("cust_type").toString();
    }
    String cust_type = "";
    Hashtable list = this.comm.getOneCompara("12", type);
    if (list.get("para_code1") != null) {
      cust_type = list.get("para_code1").toString();
    }

    return cust_type;
  }

  public String getcustAttr(Map map)
  {
    String attr = "";
    String cat_name = "";
    Ts_categoryInfo category = new Ts_categoryInfo();
    if ((map.get("class_attr") != null) && (!map.get("class_attr").toString().equals(""))) {
      attr = map.get("class_attr").toString();
      String[] catIds = attr.split("\\|");
      if (!catIds.equals("")) {
        for (int k = 0; k < catIds.length; k++) {
          cat_name = cat_name + category.getCatNameById(catIds[k]) + "&nbsp;";
        }
      }
    }

    return cat_name;
  }

  public String getclientStatus(Map map)
  {
    String clientStatus = ""; String client_status = "";
    Hashtable list = new Hashtable();
    if ((map.get("client_status") != null) && (!map.get("client_status").toString().equals(""))) {
      clientStatus = map.get("client_status").toString();
      String[] catIds = clientStatus.split("\\|");
      if (!catIds.equals("")) {
        for (int k = 0; k < catIds.length; k++) {
          list = this.comm.getOneCompara("73", catIds[k]);
          if (list.get("para_code1") != null) {
            client_status = client_status + list.get("para_code1").toString() + "&nbsp;";
          }
        }
      }
    }
    return client_status;
  }

  public String getareaAttr(Map map)
  {
    String attr = "";
    String area_name = "";
    Ts_areaInfo area = new Ts_areaInfo();
    if ((map.get("area_attr") != null) && (!map.get("area_attr").toString().equals(""))) {
      attr = map.get("area_attr").toString();
      String[] catIds = attr.split("\\|");
      if (!catIds.equals("")) {
        for (int k = 0; k < catIds.length; k++) {
          area_name = area_name + area.getAreaNameById(catIds[k]) + "&nbsp;";
        }
      }
    }

    return area_name;
  }

  public String getlocationAttr(Map map)
  {
    String attr = "";
    String area_name = "";
    Ts_areaInfo area = new Ts_areaInfo();
    if ((map.get("account_location") != null) && (!map.get("account_location").toString().equals(""))) {
      attr = map.get("account_location").toString();
      String[] catIds = attr.split("\\|");
      if (!catIds.equals("")) {
        for (int k = 0; k < catIds.length; k++) {
          area_name = area_name + area.getAreaNameById(catIds[k]) + "&nbsp;";
        }
      }
    }
    return area_name;
  }

  public String getwork_addr(Map map)
  {
    String attr = "";
    String area_name = "";
    Ts_areaInfo area = new Ts_areaInfo();
    if ((map.get("q_work_addr") != null) && (!map.get("q_work_addr").toString().equals(""))) {
      attr = map.get("q_work_addr").toString();
      String[] catIds = attr.split("\\|");
      if (!catIds.equals("")) {
        for (int k = 0; k < catIds.length; k++) {
          area_name = area_name + area.getAreaNameById(catIds[k]) + "&nbsp;";
        }
      }
    }
    return area_name;
  }

  public String getStartAddr(Map map)
  {
    String attr = "";
    String area_name = "";
    Ts_areaInfo area = new Ts_areaInfo();
    if ((map.get("start_addr") != null) && (!map.get("start_addr").toString().equals(""))) {
      attr = map.get("start_addr").toString();
      String[] catIds = attr.split("\\|");
      if (!catIds.equals("")) {
        for (int k = 0; k < catIds.length; k++) {
          area_name = area.getAreaNameById(catIds[k]) + "&nbsp;";
        }
      }
    }
    return area_name;
  }

  public String getEndAddr(Map map)
  {
    String attr = "";
    String area_name = "";
    Ts_areaInfo area = new Ts_areaInfo();
    if ((map.get("end_addr") != null) && (!map.get("end_addr").toString().equals(""))) {
      attr = map.get("end_addr").toString();
      String[] catIds = attr.split("\\|");
      if (!catIds.equals("")) {
        for (int k = 0; k < catIds.length; k++) {
          area_name = area.getAreaNameById(catIds[k]) + "&nbsp;";
        }
      }
    }
    return area_name;
  }

  public String getcustImg(Map map)
  {
    String img = "";
    String custImg = "";
    Ti_attachInfo attach = new Ti_attachInfo();
    if ((map.get("info_id") != null) && (!map.get("info_id").toString().equals(""))) {
      img = map.get("info_id").toString();
      custImg = attach.getFilePathByAttachrootid(img);
    }

    return custImg;
  }

  public String getTradeState(Map map)
  {
    Ti_tradestateInfo tadestate_info = new Ti_tradestateInfo();
    CommparaIndexFiles commparaIndex = new CommparaIndexFiles();
    String trade_state = "1";
    String trade_state_string = "";
    if ((map.get("info_id") != null) && (!map.get("info_id").toString().equals(""))) {
      trade_state = tadestate_info.getTradeStateByID(map.get("info_id").toString());
      trade_state_string = commparaIndex.getComparaNameByID("74", "para_code2", trade_state, "para_code1");
      if (trade_state.equals("1"))
        trade_state_string = "<font style='color:#666666'>" + trade_state_string + "</font>";
      else if (trade_state.equals("2"))
        trade_state_string = "<font style='color:GREEN'>" + trade_state_string + "</font>";
      else if (trade_state.equals("3")) {
        trade_state_string = "<font style='color:RED'>" + trade_state_string + "</font>";
      }
    }
    return trade_state_string;
  }
}